package com.example.lms.service.imp;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.lms.entity.ShipmentRecords;
import com.example.lms.mapper.ShipmentRecordsMapper;
import com.example.lms.service.ShipmentRecordsService;
import com.example.lms.vo.D;
import com.example.lms.vo.OneCustomersGoodes;
import org.springframework.stereotype.Service;

import java.util.UUID;

/**
 * @module
 * @author：DUOLUONIANDAI
 * @DATA：2024/05/11
 * @Title：
 */

@Service
public class ShipmentRecordsServiceImp extends ServiceImpl<ShipmentRecordsMapper, ShipmentRecords> implements ShipmentRecordsService {


    @Override
    public D addSR(ShipmentRecords shipmentRecords) {
        shipmentRecords.setId(UUID.randomUUID().toString());
        boolean save = save(shipmentRecords);
        D build = D.builder().build();
        build.inputVal("保存信息",shipmentRecords);
        build.inputVal("保存是否成功",save);

        return build;
    }

    @Override
    public D delSR(String id) {
        ShipmentRecords id1 = getOne(new QueryWrapper<ShipmentRecords>().eq("id", id));
        D build = D.builder().build();
        if (ObjectUtils.isEmpty(id1)){
            build.inputVal("删除信息不存在！",id);
            return build;
        }

        boolean id2 = remove(new QueryWrapper<ShipmentRecords>().eq("id", id));
        build.inputVal("删除信息为：",id1);
        build.inputVal("是否删除",id2);
        return build;
    }

    @Override
    public D querySROne(String id) {
        OneCustomersGoodes oneUserGoodesInfo = super.baseMapper.getOneUserGoodesInfo(id);
        D build = D.builder().build();
        build.inputVal("查询信息:",oneUserGoodesInfo);
        return build;
    }
}
